import http from './interface'
import Fpublic from '../../common/config.js'
/**
 * 将业务所有接口统一起来便于维护
 * 如果项目很大可以将 url 独立成文件，接口分成不同的模块
 * 
 */

// 单独导出(测试接口) import {test} from '@/common/vmeitime-http/'
function getHeader(){
	const e = {};
	    '[object String]' === Object.prototype.toString.call(uni.getStorageSync('cooks')) ? (e['content-type'] = 'application/x-www-form-urlencoded', e.fcard = Math.round(new Date().getTime() / 1e3), e.Cookie = 'ASP.NET_SessionId=' + uni.getStorageSync('cooks')) : (e['content-type'] = 'application/x-www-form-urlencoded', e.fcard = Math.round(new Date().getTime() / 1e3));
	    Fpublic.aAppId?e.AppId = Fpublic.aAppId:'';
	    Fpublic.aAppId?e.secret = Fpublic.secret:'';
	return e
}



export const login = (data) => {
	/* http.config.baseUrl = "http://localhost:8080/api/"
	//设置请求前拦截器
	http.interceptor.request = (config) => {
		config.header = {
			"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		}
	} */
	//设置请求结束后拦截器
	http.interceptor.response = (response) => {
		console.log('个性化response....')
		//判断返回状态 执行相应操作
		return response;
	}
    return http.request({
        url: 'MicroApp/Login',
		method:'POST',
		dataType: 'json',
        data
		
    })
}

// e
export const getQrCode = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'MicroApp/QRCode',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const setCardNumber = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'MicroApp/CardData',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetCustomerList = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/GetCustomerList',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetDoorList = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/GetDoorList',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const DoorActivity = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/DoorActivity',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const OpenDoor = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'AsyncDoor/OpenDoor',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetDoorRecord = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/GetDoorRecord',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetAccessGroup = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Visitor/GetAccessGroup',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetDoorValidType = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Visitor/GetDoorValidType',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const AddVisitor = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Visitor/AddVisitor',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const Complete = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Visitor/Complete',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const GetVisitorList = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Visitor/GetVisitorList',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const AddCustomer = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/AddCustomer',
        method: 'POST', 
        data,
		header:getHeader()
    })
}

export const DeleteCustomer = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/DeleteCustomer',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const Update = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'Door/Update',
        method: 'POST', 
        data,
		header:getHeader()
    })
}

export const Upload = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'door/Upload',
        method: 'POST', 
        data,
		header:getHeader()
    })
}
export const Logup = (data) => {
	// console.error(Vue.$Fpublic)
    return http.request({
        url: 'MicroApp/Logup',
        method: 'POST', 
        data,
		header:getHeader()
    })
}


// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	login,getQrCode,
	setCardNumber,
	GetCustomerList,
	GetDoorList,
	DoorActivity,
	OpenDoor,GetDoorRecord,
	GetAccessGroup,
	GetDoorValidType,AddVisitor,Complete,GetVisitorList,
	AddCustomer,
	DeleteCustomer,
	Update,Upload,
	Logup
}